﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Xml;
using System.IO;
using System.Drawing;
using Vibz.Common;
using Vibz.Common.Notification;
using Vibz.Common.Model;

namespace Vibz.Game.Bugs.Model
{
    [Serializable]
    public class Ground : ModelBase
    {
        [XmlElement("o")]
        public List<GroundObject> Objects = new List<GroundObject>();

        [XmlElement("l")]
        public int Width { get; set; }
        [XmlElement("w")]
        public int Height { get; set; }
        public Ground() { }
        public Ground(int length, int width) { Width = length; Height = width; }

        [XmlIgnore]
        public List<Player> Players { get { return this.Objects.OfType<Player>().ToList(); } }
        [XmlIgnore]
        public List<Power> Powers { get { return this.Objects.OfType<Power>().ToList(); } }
        [XmlIgnore]
        public List<Coin> Coins { get { return this.Objects.OfType<Coin>().ToList(); } }
        [XmlIgnore]
        public List<Obstacle> Obstacles { get { return this.Objects.OfType<Obstacle>().ToList(); } }
        [XmlIgnore]
        public List<Compartment> Compartments { get { return this.Objects.OfType<Compartment>().ToList(); } }
        
        
        GroundObject Find(int id)
        {
            return (GroundObject)Objects.Find(go => go.ID == id);
        }
    }
}
